/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.userbill.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author 毛晋辉
* @date 2020-09-02
**/
@Entity
@Data
@Table(name="user_bill")
public class UserBill implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "账单id")
    private Long id;

    @Column(name = "user_id",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "用户id")
    private String userId;

    @Column(name = "link_id")
    @ApiModelProperty(value = "关联id")
    private String linkId;

    @Column(name = "pm")
    @ApiModelProperty(value = "0：支出；1：收入；")
    private Integer pm;

    @Column(name = "title")
    @ApiModelProperty(value = "标题")
    private String title;

    @Column(name = "category")
    @ApiModelProperty(value = "种类")
    private String category;

    @Column(name = "type",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "类型")
    private String type;

    @Column(name = "number")
    @ApiModelProperty(value = "数字")
    private BigDecimal number;

    @Column(name = "balance")
    @ApiModelProperty(value = "剩余金额")
    private BigDecimal balance;

    @Column(name = "mark")
    @ApiModelProperty(value = "备注")
    private String mark;

    @Column(name = "status")
    @ApiModelProperty(value = "0:待确定；1：有效；-1无效")
    private Integer status;

    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间")
    private Timestamp createTime;

    public void copy(UserBill source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}